import request from '@/utils/request'

// Mock数据
const mockReceiverList = [
  {
    receiverId: 1,
    receiverName: '上海收货公司',
    contactPerson: '陈经理',
    contactPhone: '13900139001',
    address: '上海市浦东新区陆家嘴金融区',
    createTime: '2024-01-11 11:00:00'
  },
  {
    receiverId: 2,
    receiverName: '深圳收货公司',
    contactPerson: '刘经理',
    contactPhone: '13900139002',
    address: '深圳市福田区中心区',
    createTime: '2024-01-13 15:30:00'
  },
  {
    receiverId: 3,
    receiverName: '杭州收货公司',
    contactPerson: '赵经理',
    contactPhone: '13900139003',
    address: '杭州市西湖区文三路',
    createTime: '2024-01-15 09:20:00'
  }
]

// 查询收货方列表
export function listReceiver(query) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '操作成功',
        rows: mockReceiverList,
        total: mockReceiverList.length
      })
    }, 300)
  })
}

// 查询收货方详细
export function getReceiver(receiverId) {
  return new Promise((resolve) => {
    setTimeout(() => {
      const receiver = mockReceiverList.find(item => item.receiverId == receiverId) || mockReceiverList[0]
      resolve({
        code: 200,
        msg: '操作成功',
        data: receiver
      })
    }, 300)
  })
}

// 新增收货方
export function addReceiver(data) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '新增成功'
      })
    }, 800)
  })
}

// 修改收货方
export function updateReceiver(data) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '修改成功'
      })
    }, 800)
  })
}

// 删除收货方
export function delReceiver(receiverId) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '删除成功'
      })
    }, 500)
  })
}

// 导出收货方
export function exportReceiver(query) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: '导出成功'
      })
    }, 1000)
  })
}